#!_*_ coding: utf8 _*_
from django.contrib.auth.models import User
from django.db import models

from wx.wxcommon.models import WechatUserInfo

ROLE_TYPE = (
    (0, u'未知'),
    (1, u'老师'),
    (2, u'学生'),
    (3, u'教务'),
)


class RoleField(models.SmallIntegerField):
    def __init__(self, *args, **kwargs):
        kwargs['choices'] = ROLE_TYPE
        super(RoleField, self).__init__(*args, **kwargs)


# Create your models here.
class WXUser(WechatUserInfo):
    user = models.ForeignKey(User, on_delete=models.PROTECT, blank=True, null=True)

    def __str__(self):
        return self.user and self.user.first_name or self.nick_name

    class Meta:
        verbose_name = u'微信用户'
        verbose_name_plural = u'微信用户'
